#include <stdio.h>
#include <string>

using namespace std;

class Solution {
public:
    int firstUniqChar(string s) {
        int length = s.length();
        int flag[26][2] = {0};
        for(int i = 0; i < length; ++i)
        {
            flag[s[i]-'a'][0] = i;
            ++flag[s[i]-'a'][1];
        }
        int min = length;
        for(int i = 0; i < 26; ++i)
        {
            if(flag[i][1] == 1 && flag[i][0] < min)
                min = flag[i][0];
        }
        if(min != length)
            return min;
        return -1;
    }
};
